<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<%@ taglib prefix="sec"
	uri="http://www.springframework.org/security/tags"%>

<s:include value="../header.jsp"></s:include>
<s:include value="../leftNav.jsp"></s:include>

<div id="content">

<div id="tabs">
	<ul>
		<li><s:a href="#tabs-1" action="testActionJsp.action">Edit issue</s:a></li>
		<li><s:a href="#tabs-2" action="testActionJsp.action">Issue details</s:a></li>
		<li><s:a href="#tabs-3" action="testActionJsp.action">Notification Area</s:a></li>
		<li><s:a href="#tabs-4" action="testActionJsp.action">Attachments</s:a></li>
		<li><s:a href="#tabs-5" action="testActionJsp.action">Links</s:a></li>
	</ul>
	<div id="tabs-1">
 		<p>Create Issue</p>
		<s:form name="addForm" method="post" action="editIssueForm.action" theme="xhtml">
			<s:textfield name="title" label="Title" size="60"/>
			<s:textarea label="Description" name="description" cols="60" rows="6"/>
			<sec:authorize  access="hasRole('ROLE_ADMIN')">
				<s:checkbox name="confirmed" fieldValue="true" label="Confirmed"/>
			</sec:authorize>
			<sec:authorize  access="hasRole('PROJECT_MANAGER')">
				<s:checkbox name="confirmed" fieldValue="true" label="Confirmed"/>
			</sec:authorize>
			<s:select label="Iteration" headerKey="-1"
				headerValue="Choose iteration" list="iterations" name="iterationSlt" />
			<s:select label="Type" headerKey="-1"
				headerValue="types" list="types" name="type" />
			<s:select label="Priority" headerKey="-1"
				headerValue="Priorities" list="priorities" name="priority" />
			<s:select label="Team" headerKey="-1"
				headerValue="teams" list="teams" name="team" />
			<s:textfield name="estimationHours" label="Estimation (hours)" size="10"/>
			<sx:datetimepicker name="estimationTime" label="Estimation (date)" 
				displayFormat="dd-MMM-yyyy" value="todayDate" />
			<s:submit type="button" name="Add" label="Save" />
		</s:form>
	</div>
	<div id="tabs-2">
		<div id="accordion">
			<div>
				<h3><a href="#">Step By Step</a></h3>
				<s:form name="addForm" method="post" action="editIssueForm.action" theme="xhtml">
					<s:textarea name="stepByStep" cols="80" rows="15"/>
					<s:submit type="button" name="Add" label="Save"/>
				</s:form>
			</div>
			<div>
				<h3><a href="#">Source code</a></h3>
				<s:form name="addForm" method="post" action="editIssueForm.action" theme="xhtml">
					<s:textarea name="sourceCode" cols="80" rows="15"/>
					<s:submit type="button" name="Add" label="Save"/>
				</s:form>
			</div>
			<div>
				<h3><a href="#">System Configuration</a></h3>
				<s:form name="addForm" method="post" action="editIssueForm.action" theme="xhtml">
					<s:textarea name="systemConfiguration" cols="80" rows="15"/>
					<s:submit type="button" name="Add" label="Save"/>
				</s:form>
			</div>
			<div>
				<h3><a href="#">Workaround</a></h3>
				<s:form name="addForm" method="post" action="editIssueForm.action" theme="xhtml">
					<s:textarea name="workaround" cols="80" rows="15"/>
					<s:submit type="button" name="Add" label="Save"/>
				</s:form>
			</div>
		</div>
	</div>
	<div id="tabs-3">
 		<h3>Notification Area</h3>
		<s:form name="addForm" method="post" action="editNotificationArea.action" theme="xhtml">
			<sx:autocompleter label="Add user" list="usersSystem" name="addedUser" size="30"/>
			<s:submit type="button" name="Add" label="Add"/>
		</s:form>
		
		<s:if test="notificatedUsers.size > 0">
			<h3>Users already added to notification area:</h3>
			<table id="notificatedUsers">
				<tr>
						<td>Username:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
						<td>User email:</td>
				</tr>
				<s:iterator value="notificatedUsers">
					<tr>
						<td><s:property value="username" /></td>
						<td><s:property value="email" /></td>
						<td><s:url id="deleteUser" value="removeNotification.action">
								<s:param name="userId" value="userId" />
							</s:url> <s:a href="%{deleteUser}">Remove</s:a>
						</td>
					</tr>
				</s:iterator>
			</table>
		</s:if>
		<s:else>
			<h3>Notification area is empty.</h3>
		</s:else>
	</div>
	<div id="tabs-4">
 		<h3>Attachments</h3>
		<s:form name="addForm" method="post" action="addAttachment.action" enctype="multipart/form-data" theme="xhtml">
			<s:file name="fileUpload" label="Select a File to upload" size="40" />
			<s:submit type="button" name="Add" label="Add"/>
		</s:form>
		<s:if test="attachments.size > 0">
			<h3>Attachment related with this issue:</h3>
			<table id="attachments">
				<tr>
						<td>File name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
						<td>Content type:</td>
				</tr>
				<s:iterator value="attachments">
					<tr>
						<td><s:property value="fileName" /></td>
						<td><s:property value="contentType" /></td>
						<td><s:url id="deleteAttachment" value="removeAttachment.action">
								<s:param name="attachmentId" value="attachmentId" />
							</s:url> <s:a href="%{deleteAttachment}">Remove</s:a>
						</td>
					</tr>
				</s:iterator>
			</table>
		</s:if>
	</div>
	<div id="tabs-5">
 		<h3>Links</h3>
 		<s:form name="addForm" method="post" action="addIssueLink.action" theme="xhtml">
			<s:textfield name="link" label="Link" size="60"/>
			<s:textarea label="Comment" name="comment" cols="60" rows="4"/>
			<s:submit type="button" name="Add" label="Add"/>
		</s:form>
 		
		<s:if test="issueLinks.size > 0">
			<h3>Issues related with this issue:</h3>
			<table id="issueLinks">
				<tr>
						<td>Issue id:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
						<td>Comment:</td>
				</tr>
				<s:iterator value="issueLinks">
					<tr>
						<td>
							<s:url id="showIssue" value="showIssue.action">
								<s:param name="issueId" value="link"/>
							</s:url>
							<s:a href="%{showIssue}">${link}</s:a>
						</td>
						<td><s:property value="comment" /></td>
						<td><s:url id="removeIssueLink" value="removeIssueLink.action">
								<s:param name="issueLinksId" value="issueLinksId" />
							</s:url> <s:a href="%{removeIssueLink}">Remove</s:a>
						</td>
					</tr>
				</s:iterator>
			</table>
		</s:if>
		<s:else>
			<h3>This issue is not related with other issues.</h3>
		</s:else>
	</div>
</div>
</div>
</body>
</html>